// @FileName  :seat.c
// @Time      :2024/5/20 16:58
// @Author    :YKW
//# include <bits/stdc++.h>
//using namespace std;
# include <stdio.h>
# include <stdlib.h>
# include <math.h>
# include <string.h>
# include <stdlib.h>

#define max2(a, b) ((a) > (b) ? (a) : (b))
#define min2(a, b) ((a) < (b) ? (a) : (b))
struct info {
    int id, seat;
    char name[25];
} all[150];
int n, cnt, m, q, end2, seat[150];

int cmp_seat(const void *a, const void *b) {//升序
    struct info *p = (struct info *) a, *q = (struct info *) b;
    if (p->seat == q->seat) return p->id - q->id;
    return p->seat - q->seat;
}

int cmp_id(const void *a, const void *b) {//升序
    struct info *p = (struct info *) a, *q = (struct info *) b;
    return p->id - q->id;
}

int main() {
    setbuf(stdout, NULL);
    scanf("%d", &n);
    FILE *fin = fopen("in.txt", "r");
    while (fscanf(fin, "%d%s%d", &all[cnt].id, all[cnt].name, &all[cnt].seat) != EOF) {
        seat[all[cnt].seat]++;
        m = max2(m, all[cnt].seat);
        cnt++;
    }
    //1
    qsort(all, n, sizeof(struct info), cmp_seat);
    //2
    q = min2(n, m);
    end2 = n - 1;
    for (int i = 1; i <= q; i++) {
        if (seat[i] == 0) {
            seat[i]++;
            seat[all[end2].seat]--;
            all[end2--].seat = i;
        }
        m = all[end2].seat;
        q = min2(n, m);
    }
    qsort(all, n, sizeof(struct info), cmp_seat);
    //3
    m = all[n - 1].seat;
    for (int i = 1; i < n; i++) {
        if (all[i].seat == all[i - 1].seat)
            all[i].seat = ++m;
    }
    qsort(all, n, sizeof(struct info), cmp_id);
    freopen("out.txt", "w", stdout);
    for (int i = 0; i < n; i++)
        printf("%d %s %d\n", all[i].id, all[i].name, all[i].seat);
    fclose(stdout);
}